package com.gzgxzc.czh.administrator.smoke;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.gzgxzc.czh.administrator.smoke.Activity.Build_meaning_activity;
import com.gzgxzc.czh.administrator.smoke.Activity.Push_activity;
import com.gzgxzc.czh.administrator.smoke.Activity.Weather_activity;
import com.gzgxzc.czh.administrator.smoke.Activity.Work_instruction_activity;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
        private ListView lv_home;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        lv_home = (ListView) findViewById(R.id.lv_home);

        lv_home = new ListView(this);
        lv_home.setAdapter(new ArrayAdapter<String>
                (this, android.R.layout.simple_expandable_list_item_1,getData()));
        setContentView(lv_home);
    }
    private List<String> getData() {

        final List<String> data = new ArrayList<String>();
        data.add("推送");
        data.add("意见建议");
        data.add("工作指导");
        data.add("天气预报");
       lv_home.setOnItemClickListener(new AdapterView.OnItemClickListener() {
           @Override
           public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

               if (data.get(position).equals("推送")){
                   Intent intent = new Intent(MainActivity.this,Push_activity.class);
                   startActivity(intent);
               }
               if (data.get(position).equals("意见建议")){
                   Intent intent = new Intent(MainActivity.this,Build_meaning_activity.class);
                   startActivity(intent);
               }
               if (data.get(position).equals("工作指导")){
                   Intent intent = new Intent(MainActivity.this,Work_instruction_activity.class);
                   startActivity(intent);
               }
               if (data.get(position).equals("天气预报")){
                   Intent intent = new Intent(MainActivity.this,Weather_activity.class);
                   startActivity(intent);
               }
           }
       });

        return data;
    }

}
